import {defineConfig, loadEnv} from 'vite'
import vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite'
import {
    AntDesignVueResolver
} from 'unplugin-vue-components/resolvers'

//@ts-ignore
const { resolve } = require('path')
// @ts-ignore
const process = require('process')

// https://vitejs.dev/config/
export default ({mode}) => defineConfig({
    define: {
        'process.env': loadEnv(mode, process.cwd())
    },
    base: "/",
    css: {
        preprocessorOptions: {
            less: {
                javascriptEnabled: true
            }
        }
    },
    plugins: [
        vue(),
        Components({
            resolvers: [
                AntDesignVueResolver()
            ]
        })
    ],
    resolve: {
        alias: {
            //@ts-ignore
            "@c": resolve(__dirname, "src/components"),
            //@ts-ignore
            "@v": resolve(__dirname, "src/views"),
            //@ts-ignore
            "@": resolve(__dirname, "src"),
        },
        extensions: ['.js', '.json', '.ts']
    },
    build:{
        target:['edge90','chrome90','firefox90','safari15']
    }
})
